package net.sareweb.acab.entity.manager;

import java.util.List;

import net.sareweb.acab.entity.Country;
import net.sareweb.acab.entity.Request;
import net.sareweb.acab.entity.State;
import net.sareweb.acab.entity.User;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Name("stateManager")
@Scope(ScopeType.CONVERSATION)
public class StateManager extends CommonManager<State> {
	
	private final String queryFindByCountry="from State where country.idCountry=:idCountry";
	
	public List<State> findByCountry(Country country){
		if(country==null) return null;
		return findByCountry(country.getIdCountry());
	} 
	public List<State> findByCountry(Integer idCountry){
		List<State> l = entityManager.createQuery(queryFindByCountry).setParameter("idCountry",idCountry).getResultList();
		return l;
	} 
	
}
